﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Transactions;
using T.FAS.Runtime.Base.Dao;
using T.FAS.Runtime.Base.Entity;

namespace T.FAS.Runtime.Base.Service
{
    public class FASRouterService
    {
        private readonly FASRouterDao _fasRouter = new FASRouterDao();

        /// <summary>
        /// 获取当前router表中存在的所有Set及随机的一个appid，用作路由，发布工具使用
        /// </summary>
        /// <returns></returns>
        public List<FASRouter> GetAllSetDevappids()
        {
            var list = _fasRouter.GetAllRouters();
            var routers = new List<FASRouter>();
            for (int i = 0; i < list.Count; i++)
            {
                if(!routers.Exists(t=>t.ServiceSetID == list[i].ServiceSetID) && list[i].DevAppID != "fascommon")
                {
                    routers.Add(list[i]);
                }
            }
            return routers;
        }

        /// <summary>
        /// 获取当前router路由表，wf根据子系统获取targetSetID使用
        /// </summary>
        /// <returns></returns>
        public List<FASRouter> GetAllRouters()
        {
            return _fasRouter.GetAllRouters();
        }
    }
}
